import { createRouter, createWebHistory, type RouteRecordRaw, createWebHashHistory } from 'vue-router'
//?配置自动路由
// import { routes } from 'vue-router/auto-routes'
// const router = createRouter({
//   history: createWebHistory(),
//   routes: routes//使用自动路由
// })
//!导入day1211
import studemo1 from '@/views/day1211/studemo1.vue'
import studemo2 from '@/views/day1211/studemo2.vue'
import studemo3 from '@/views/day1211/studemo3.vue'
import studemo4 from '@/views/day1211/studemo4.vue'
import studemo5 from '@/views/day1211/studemo5.vue'
import studemo6 from '@/views/day1211/studemo6.jsx'
import studemo7 from '@/views/day1211/studemo7.vue'
import studemo8 from '@/views/day1211/studemo8.vue'
import studemo9 from '@/views/day1211/studemo9.vue'
import studemo10 from '@/views/day1211/studemo10.vue'
import studemo11 from '@/views/day1211/studemo11.vue'
import tab切换 from '@/views/day1211/tab切换.vue'
import 计算器 from '@/views/day1211/计算器.vue'
import studemo12 from '@/views/day1211/studemo12.vue'
import 绑定HTML类名 from '@/views/day1211/绑定HTML类名.vue'
import 学生管理系统 from '@/views/day1211/学生管理系统.vue'
//定义路由表
const routesday1211: Array<RouteRecordRaw> = [
  {
    path: '/studemo1',
    name: 'studemo1',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1211/studemo1.vue'),
  },
  {
    path: '/studemo2',
    name: 'studemo2',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1211/studemo2.vue'),
  },
  {
    path: '/studemo3',
    name: 'studemo3',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: studemo3
  },
  {
    path: '/studemo4',
    name: 'studemo4',
    component: studemo4
  },
  {
    path: '/studemo5',
    name: 'studemo5',
    component: studemo5
  },
  {
    path: '/studemo6',
    name: 'studemo6',
    component: studemo6
  },
  {
    path: '/studemo7',
    name: 'studemo7',
    component: studemo7
  },
  {
    path: '/studemo8',
    name: 'studemo8',
    component: studemo8
  },
  {
    path: '/studemo9',
    name: 'studemo9',
    component: studemo9
  },
  {
    path: '/studemo10',
    name: 'studemo10',
    component: studemo10
  },
  {
    path: '/studemo11',
    name: 'studemo11',
    component: studemo11
  },
  {
    path: '/tab切换',
    name: 'tab切换',
    component: tab切换
  },
  {
    path: '/计算器',
    name: '计算器',
    component: 计算器
  },
  {
    path: '/studemo12',
    name: 'studemo12',
    component: studemo12
  },
  {
    path: '/绑定HTML类名',
    name: '绑定HTML类名',
    component: 绑定HTML类名
  },
  {
    path: '/学生管理系统',
    name: '学生管理系统',
    component: 学生管理系统
  }
]

//!导入day1217
import Proxy from '@/views/day1217/Proxy.vue'
import ReactiveProxy from '@/views/day1217/ReactiveProxy.vue'
import ref解包 from '@/views/day1217/ref解包.vue'
//定义路由表
const routesday1217: Array<RouteRecordRaw> = [
  {
    path: '/Proxy',
    name: 'Proxy',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1217/Proxy.vue'),
  },
  {
    path: '/ReactiveProxy',
    name: 'ReactiveProxy',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1217/ReactiveProxy.vue'),
  },
  {
    path: '/ref解包',
    name: 'ref解包',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1217/ref解包.vue'),
  },
]

//!导入day1218
import API from '@/views/day1218/API.vue'
import customRef from '@/views/day1218/customRef.vue'
const routesday1218: Array<RouteRecordRaw> = [
  {
    path: '/API',
    name: 'API',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1218/API.vue'),
  },
  {
    path: '/customRef',
    name: 'customRef',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1218/customRef.vue'),
  },
]


//!导入day1219
import 案例2 from '@/views/day1219/案例2.vue'
import 钩子函数 from '@/views/day1219/钩子函数.vue'
import effectScope from '@/views/day1219/effectScope.vue'
import effectScope改造 from '@/views/day1219/effectScope改造.vue'
import effectScope案例 from '@/views/day1219/effectScope案例.vue'
const routesday1219: Array<RouteRecordRaw> = [
  {
    path: '/案例2',
    name: '案例2',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1219/案例2.vue'),
  },
  {
    path: '/钩子函数',
    name: '钩子函数',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1219/钩子函数.vue'),
  },
  {
    path: '/effectScope',
    name: 'effectScope',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1219/effectScope.vue'),
  },
  {
    path: '/effectScope改造',
    name: 'effectScope改造',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1219/effectScope改造.vue'),
  },
  {
    path: '/effectScope案例',
    name: 'effectScope案例',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1219/effectScope案例.vue'),
  },
]


//!导入day1220
import 防抖函数 from '@/views/day1220/防抖函数.vue'
import 计算属性 from '@/views/day1220/计算属性.vue'
import 侦听器使用场景 from '@/views/day1220/侦听器使用场景.vue'
import 侦听器watch from '@/views/day1220/侦听器watch.vue'
import 侦听器watchEffect from '@/views/day1220/侦听器watchEffect.vue'
const routesday1220: Array<RouteRecordRaw> = [
  {
    path: '/防抖函数',
    name: '防抖函数',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1220/防抖函数.vue'),
  },
  {
    path: '/计算属性',
    name: '计算属性',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1220/计算属性.vue'),
  },
  {
    path: '/侦听器使用场景',
    name: '侦听器使用场景',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1220/侦听器使用场景.vue'),
  },
  {
    path: '/侦听器watch',
    name: '侦听器watch',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1220/侦听器watch.vue'),
  },
  {
    path: '/侦听器watchEffect',
    name: '侦听器watchEffect',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1220/侦听器watchEffect.vue'),
  },
]


//!导入day1223
import 案例学生管理系统 from '@/views/day1223/案例学生管理系统.vue'
const routesday1223: Array<RouteRecordRaw> = [
  {
    path: '/案例学生管理系统',
    name: '案例学生管理系统',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1223/案例学生管理系统.vue'),
  }
]


//!导入day1224
import 组件传值props from '@/views/day1224/组件传值props.vue'
import 组件注册和引入 from '@/views/day1224/组件注册和引入.vue'
const routesday1224: Array<RouteRecordRaw> = [
  {
    path: '/组件传值props',
    name: '组件传值props',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1224/组件传值props.vue'),
  },
  {
    path: '/组件注册和引入',
    name: '组件注册和引入',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1224/组件注册和引入.vue'),
  }
]


//!导入day1225
import 插槽solt from '@/views/day1225/插槽solt.vue'
import 响应式props解构 from '@/views/day1225/响应式props解构.vue'
import 组件时间emit from '@/views/day1225/组件时间emit.vue'
const routesday1225: Array<RouteRecordRaw> = [
  {
    path: '/插槽solt',
    name: '插槽solt',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1225/插槽solt.vue'),
  },
  {
    path: '/响应式props解构',
    name: '响应式props解构',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1225/响应式props解构.vue'),
  },
  {
    path: '/组件时间emit',
    name: '组件时间emit',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1225/组件时间emit.vue'),
  }
]


//!导入day1226
import moon from '@/views/day1226/moon.vue'
import star from '@/views/day1226/star.vue'
import wucyu from '@/views/day1226/wucyu.vue'
const routesday1226: Array<RouteRecordRaw> = [
  {
    path: '/moon',
    name: 'moon',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1226/moon.vue'),
  },
  {
    path: '/star',
    name: 'star',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1226/star.vue'),
  },
  {
    path: '/wucyu',
    name: 'wucyu',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1226/wucyu.vue'),
  }
]


//!导入day1227
import vmodel from '@/views/day1227/vmodel.vue'
const routesday1227: Array<RouteRecordRaw> = [
  {
    path: '/vmodel',
    name: 'vmodel',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1227/vmodel.vue'),
  },
]


//!导入day1230
import 修改学生系统 from '@/views/day1230/修改学生系统.vue'
import defineExpose from '@/views/day1230/defineExpose.vue'
const routesday1230: Array<RouteRecordRaw> = [
  {
    path: '/修改学生系统',
    name: '修改学生系统',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1230/修改学生系统.vue'),
  },
  {
    path: '/defineExpose',
    name: 'defineExpose',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day1230/defineExpose.vue'),
  },
]

//!导入day0102
import vuerouter from '@/views/day0102/2025.vue';
import 嵌套路由 from '@/views/day0102/嵌套路由.vue';
import 动态路由 from '@/views/day0102/动态路由.vue'
const routesday0102: Array<RouteRecordRaw> = [
  {
    path: '/2025',
    name: 'vuerouter',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day0102/2025.vue'),
  },
  {
    path: '/嵌套路由',
    name: '嵌套路由',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day0102/嵌套路由.vue'),
    children: [
      {
        path: '/嵌套路由/',
        name: 'SearchHistory',
        component: () => import('../views/day0102/components/SearchHistory.vue'),
      },
      {
        path: '/嵌套路由/SearchHistory2',
        name: 'SearchHistory2',
        component: () => import('../views/day0102/components/SearchHistory2.vue'),
      }
    ]
  },
  {
    path: '/动态路由',
    name: '动态路由',
    component: () => import('../views/day0102/动态路由.vue'),
    children: [
      {
        path: '动态路由/:id',
        name: 'routerson',
        component: () => import('../views/day0102/components/routerson.vue'),
      }
    ],
  }
]

//!导入day0103
import demo from '@/views/day0103/demo.vue'
import 路由组件传参 from '@/views/day0103/路由组件传参.vue'
const routesday0103: Array<RouteRecordRaw> = [
  {
    path: '/demo',
    name: 'demo',
    component: () => import('../views/day0103/demo.vue'),
    children: [
      {
        path: '/demo/demoson',
        name: 'demoson',
        component: () => import('../views/day0103/components/demoson.vue'),
      },
      {
        path: '/demo/demoson1/:title/:content',
        name: 'demoson1',
        component: () => import('../views/day0103/components/demoson1.vue'),
      },
      {
        path: '/demo/demoson2',
        name: 'demoson2',
        component: () => import('../views/day0103/components/demoson2.vue'),
      },
      {
        path: '/demo/demoson3',
        name: 'demoson3',
        component: () => import('../views/day0103/components/demoson3.vue'),
      },
      {
        path: '/',
        name: 'Sons',
        component: { default: Demoson2, Sons: Demoson3 },
      },
    ]
  },
  {
    path: '/路由组件传参',
    name: '路由组件传参',
    component: () => import('../views/day0103/路由组件传参.vue'),
    children: [
      {
        path: '/路由组件传参/props',
        name: 'props',
        component: () => import('../views/day0103/components/props.vue'),
      },
      {
        path: '/路由组件传参/attrs',
        name: 'attrs',
        component: () => import('../views/day0103/components/attrs.vue'),
      }
    ]
  }
]


//!导入day0104
import 路由进阶 from '@/views/day0104/路由进阶.vue'
const routesday0104: Array<RouteRecordRaw> = [
  {
    path: '/路由进阶',
    name: '路由进阶',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day0104/路由进阶.vue'),
  },
]

//!导入day0106
import pinia from '@/views/day0106/pinia.vue'
import pinia进阶 from '@/views/day0106/pinia进阶.vue'
const routesday0106: Array<RouteRecordRaw> = [
  {
    path: '/pinia',
    name: 'pinia',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day0106/pinia.vue'),
  },
  {
    path: '/pinia进阶',
    name: 'pinia进阶',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day0106/pinia进阶.vue'),
  },
]


//!导入day0107
import fetch请求 from '@/views/day0107/fetch请求.vue'
const routesday0107: Array<RouteRecordRaw> = [
  {
    path: '/fetch请求',
    name: 'fetch请求',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day0107/fetch请求.vue'),
  },
]

//!导入day0108
import axios from '@/views/day0108/axios.vue'
const routesday0108: Array<RouteRecordRaw> = [
  {
    path: '/axios',
    name: 'axios',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day0108/axios.vue'),
  },
]

//!导入day0109
import AxiosApi from '@/views/day0109/AxiosApi.vue'
const routesday0109: Array<RouteRecordRaw> = [
  {
    path: '/AxiosApi',
    name: 'AxiosApi',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day0109/AxiosApi.vue'),
  },
]

//!导入day0110
import elementPlus from '@/views/day0110/element-plus.vue'
const routesday0110: Array<RouteRecordRaw> = [
  {
    path: '/elementPlus',
    name: 'elementPlus',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/day0110/element-plus.vue'),
  }
]
//配置主页
import HomeView from '@/views/HomeView.vue'
//配置404页面
import close from '@/views/day0102/404.vue'
//配置注册页
import Register from '@/views/register.vue'
//配置登录页
import login from '@/views/login.vue'
import Demoson2 from '../views/day0103/components/demoson2.vue'
import Demoson3 from '../views/day0103/components/demoson3.vue'
import { fromPairs } from 'lodash'
export const routerList = [
  //配置主页
  {
    path: "/",
    name: 'HomeView',
    component: HomeView,
    meta: { requiresAuth: true }//需要登录的路由
  },
  //配置404页面
  {
    path: '/:pathMatch(.*)*',
    name: 'close',
    component: close,
  },
  //配置注册页
  {
    path: '/register',
    name: 'registerView',
    component: Register,
  },
  //配置登录页

  {
    path: '/login',
    name: 'login',
    component: login,
  },
  ...routesday1211,
  ...routesday1217,
  ...routesday1218,
  ...routesday1219,
  ...routesday1220,
  ...routesday1223,
  ...routesday1224,
  ...routesday1225,
  ...routesday1226,
  ...routesday1227,
  ...routesday1230,
  ...routesday0102,
  ...routesday0103,
  ...routesday0104,
  ...routesday0106,
  ...routesday0107,
  ...routesday0108,
  ...routesday0109,
  ...routesday0110
]

//!注册路由
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: routerList
})


//!配置全局路由守卫
// router.beforeEach((to, from, next) => {
//   // 从浏览器的本地存储中获取名为'token'的项
//   // 如果'token'存在，则将其值赋给变量isAuthenticated
//   // 如果'token'不存在，则isAuthenticated的值为null
//   const isAuthenticated = localStorage.getItem('token')
//   if (isAuthenticated) {
//     // 如果已认证
//     if (to.path === '/login') {
//       // 如果已认证用户尝试访问登录页，放行
//       next();
//     } else {
//       // 对于其他已认证的访问，继续导航
//       next();
//     }
//   } else {
//     // 如果未认证
//     if (to.path === '/login' || to.path === '/register') {
//       // 如果访问的是登录页或注册页，继续导航
//       next();
//     } else {
//       // 对于其他未认证的访问，重定向到登录页
//       alert('请先登录')
//       next('/login');
//     }
//   }
// });
export default router
